<?php
include('../../include/functions.inc.php');
include('../../include/inputbuilder.inc.php');
include('../../include/maintenance.inc.php');
if (isEmpty(getParam('CODE'))) {
    echo 'WRONG PARAMETER';
} else {
    $maintenance = unserialize($_SESSION['mCycle']);
    $list = $db->query_select("cllg_entity", NULL);
    $rows = $db->query_select($maintenance->table, sprintf("CODE=%s", getParam('CODE')));

    foreach ($rows as $row) {
        ?>
        <form id="<?php echo $maintenance->formName; ?>" name="<?php echo $maintenance->formName; ?>" method="POST" action="<?php echo $maintenance->updateUrlPage; ?>">
            <table class=""  width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <th scope="col"><legend>DATOS CARRERA</legend></th>
                    <th scope="col">
                        <legend>
                            <div style="margin-left: 30%" class="btn-group">
                            <?php
                            $canActivate = $row["ACTIVITY"] == 0 ? "" : 'disabled="disabled"';
                            $canUpdate = $row["STATUS"] == 0 ? "" : 'disabled="disabled"';
                            ?>
                            <input type="button" class="btn btn-info" name="p" id="disable" <?php echo $canActivate; ?>  value="Activar" onclick="javascript:formOkBt($(this.form),activar);"  />
                            <input type="button" name="cmdOk" id="cmdOk" value="Guardar" class="btn btn-info"
                            <?php echo $canUpdate; ?>  
                            onClick="javascript:formOkBt($(this.form),updateAction);" />
                            <input type="button" name="eliminar" class="btn btn-info" id="eliminar" 
                             onclick="javascript:deleteAction('<?php echo $maintenance->deleteUrlPage; ?>',<?php echo $maintenance->getDeleteUrl(); ?>)" value="Borrar" />        
                            <input type="button" name="cmdCancel" id="cmdCancel" class="btn btn-info" value="Cancelar" onClick="loadTable();jQuery('#cmAddcontainer').show();" />
                            </div>
                         </legend>
                    </th>
                </tr>
                <tr>
                    <td colspan="2"><br/><table width="100%" border="0" cellspacing="0" cellpadding="0">

                            <tr>
                                <td width="15%">CODIGO</td>
                                <td width="85%"><input name="CODE" type="text"  value="<?php echo $row["CODE"]; ?>" id="CODE" />          </td>
                            </tr>
                            <tr>
                                <td>FECHA INICIO</td>
                                <td><input name="DATE_BEGIN" readonly="readonly"  type="text" id="DATE_BEGIN" value="<?php echo $row["DATE_BEGIN"]; ?>" /></td>
                            </tr>
                            <tr>
                                <td>FECHA FIN</td>
                                <td><input name="DATE_END" readonly="readonly" type="text" id="DATE_END" value="<?php echo $row["DATE_END"]; ?>" /></td>
                            </tr>
                            <tr>
                                <td>ENTIDAD</td>
                                <td><select name="FK_ENTITY" id="FK_ENTITY">
                                        <?php foreach ($list as $it) { ?>
                                            <option value="<?php echo $it["ID"]; ?>" 
                                            <?php
                                            if (!(strcmp($it["ID"], $row['FK_ENTITY']))) {
                                                echo "selected=\"selected\"";
                                            }
                                            ?>> 
            <?php echo $it["NAME"]; ?> </option>
        <?php } ?>
                                    </select></td>
                            </tr>



                        </table></td>
                </tr>
                <tr>
                    <td colspan="2">&nbsp;</td>
                </tr>
            </table>
        </form>  
        <?php
    }
}
?>
